<?php

namespace App\Models\V1;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Comment extends Model
{
    use SoftDeletes;
    protected $table = 'comments';
    protected $dates = ['deleted_at'];

    protected $fillable = ['user_id', 'pid', 'replay_user_id', 'body', 'up_times', 'lessons_id', 'type'];

    public function belongsToLessons()
    {
        return $this->belongsTo(Lessons::class, 'lessons_id', 'id');
    }

    public function setBodyAttribute($body)
    {
        $this->attributes['body'] = emoji_text_encode($body);
    }
}
